/*
 *
 *  ------------------------------------------------------------------
 *  Copyright © 2017 Hangzhou DtDream Technology Co.,Lt d. All rights reserved.
 *  ------------------------------------------------------------------
 *        Product:  EMR
 *    Module Name: NEZHA
 *   Date Created: 17-10-23 下午4:22
 *    Description:
 *  ------------------------------------------------------------------
 *  Modification History
 *  DATE            Name           Description
 *  ------------------------------------------------------------------
 *  2017-10-23      NEZHA EMR
 *  ------------------------------------------------------------------
 * /
 */

package org.xukai.remoting.sdk.web.api;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by moriarty on 17-2-24.
 */
public class RestAPIRegistry {

    private static final Map<String, RestAPI> API_MAP = new HashMap<>();

    static {
        API_MAP.put("submitJob", new RestAPI("/jobs", "POST"));
        API_MAP.put("getJobReport", new RestAPI("/jobs/%s", "GET"));
        API_MAP.put("getJobStmtResult", new RestAPI("/jobs/%s/stmts/%s", "GET"));
        API_MAP.put("getJobStmtLog", new RestAPI("/jobs/%s/stmts/%s/log", "GET"));
        API_MAP.put("getJobStmtTrackerInfo", new RestAPI("/jobs/%s/stmts/%s/tracker", "GET"));
        API_MAP.put("cancelJob", new RestAPI("/jobs/%s", "DELETE"));
        API_MAP.put("getTableNames", new RestAPI("/metadata?tablePattern=%s&tableTypes=%s", "OPTIONS"));
        API_MAP.put("getTables", new RestAPI("/metadata?tablePattern=%s&tableTypes=%s", "GET"));
        API_MAP.put("getTablesPaged", new RestAPI("/metadata_paged?tablePattern=%s&tableTypes=%s&pageNum=%s&pageSize=%s", "GET"));
        API_MAP.put("getTableDetail", new RestAPI("/metadata/%s", "GET"));
        API_MAP.put("showPartitions", new RestAPI("/metadata/%s/partitions?partSpec=%s", "GET"));
        API_MAP.put("createPartition", new RestAPI("/metadata/%s/createPartition", "POST"));
        API_MAP.put("getDatabaseDetail",new RestAPI("/database/metadata","GET"));
        API_MAP.put("getTableTypes",new RestAPI("/database/metadata/tableTypes","GET"));
    }

    public static RestAPI lookupByMethodName(String method) {
        return API_MAP.get(method);
    }
}
